<script setup>
import { userCountStore } from "@/stores/counter";
import { onMounted } from "vue";
import { storeToRefs } from 'pinia'

const countStore = userCountStore();
console.log(countStore);

// 数据需要使用storeToRefs 进行处理
const {count,doubleCount} = storeToRefs(countStore)

// 函数不需要
const {add} = countStore

onMounted(() => {
  countStore.getData();
});
</script>

<template>
  <div>
    <button @click="add">{{ count }}</button>
    <button>{{ doubleCount }}</button>
  </div>
  <div>
    <ul>
      <li v-for="item in countStore.data" key="{{ item.id }}">
        {{ item.name }}
      </li>
    </ul>
  </div>
</template>
